<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
</head>
<body>
<input type="text" id="age">
<p id="result"></p>
<button onclick="myFunction()">判断是否已经成年</button>
<script>
	function myFunction() {
		var result = document.getElementById("age").value;
		if (result >= 18) {
			document.getElementById("result").innerHTML = "恭喜,你已经成年了";
			document.getElementById("result").style.backgroundColor = "yellow";
			document.getElementById("result").style.color = "black";
		}
		else {
			document.getElementById("result").innerHTML = "对不起,你还未成年";
			document.getElementById("result").style.backgroundColor = "black";
//	 document.getElementById("result").style.color="red";
			document.getElementById("result").style.color = "red";
		}
	}
</script>
</body>
</html>